

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=&#34;auto&#34;>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/favicon.png">
  <link rel="icon" href="/img/favicon.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="">
  <meta name="author" content="John Doe">
  <meta name="keywords" content="">
  
  <title>广州大学ACM2021第七周训练2021.04.13 - violet apricity</title>

  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/lib/hint/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10.4.0/styles/github-gist.min.css" />
    
  

  
    <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" />
  



<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_kmeydafke9r.css">


<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.8.9","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"right","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"copy_btn":true,"image_zoom":{"enable":true},"toc":{"enable":true,"headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null}}};
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 5.4.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/">&nbsp;<strong>violet apricity</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;</a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" href="javascript:">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner" id="banner" parallax=true
         style="background: url('/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="page-header text-center fade-in-up">
            <span class="h2" id="subtitle" title="广州大学ACM2021第七周训练2021.04.13">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2021-04-16 11:08" pubdate>
        2021年4月16日 上午
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      2.4k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      38
       分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">广州大学ACM2021第七周训练2021.04.13</h1>
            
            <div class="markdown-body">
              <h1 id="广州大学ACM第七周训练"><a href="#广州大学ACM第七周训练" class="headerlink" title="广州大学ACM第七周训练"></a>广州大学ACM第七周训练</h1><p>链接：<a target="_blank" rel="noopener" href="https://vjudge.net/contest/432974">GZHUACM第七周</a><br>闲话：开始记录的第一场训练赛。这场两点开始，当天补课（高数课旷不得）所以迟到了两个小时，不过前四题很友好，后面的写不了，所以其实也没差。（怎么还押韵了）我要丢掉百度的坏习惯。之前训练没有思路就百度一下题目类型往某个算法或者思维想，并且时不时百度算法模板。在这里提醒下自己，不能白白浪费这么好的机会。<br>那么就开始吧。</p>
<h1 id="A-1的个数（简单思维-二进制）"><a href="#A-1的个数（简单思维-二进制）" class="headerlink" title="A - 1的个数（简单思维+二进制）"></a>A - 1的个数（简单思维+二进制）</h1><p>原题链接：<a target="_blank" rel="noopener" href="https://nanti.jisuanke.com/t/T1179">计蒜客 - T1179</a><br>题意：一个十进制数输出二进制下1的个数。<br>题解：很简单暴力即可，由于二进制末位与奇偶对应，所以可以不断取奇偶和右移遍历每一个二进制位。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><code class="hljs javascript">        <span class="hljs-comment">// violet apricity</span><br><span class="hljs-comment">// Do all I can do.Do good to be good.</span><br><br>#include&lt;iostream&gt;<br>#include&lt;stdio.h&gt;<br>#include&lt;cstring&gt;<br>#include&lt;string&gt;<br>#include&lt;algorithm&gt;<br>#include&lt;vector&gt;<br>#include&lt;math.h&gt;<br>#include&lt;map&gt;<br>#include&lt;sstream&gt;<br><br>#define STD using namespace std;<br>#define ll long long<br>#define db double<br>#define ldb long double<br>#define IOS std::ios::sync_with_stdio(<span class="hljs-literal">false</span>),<span class="hljs-attr">std</span>::cin.tie(<span class="hljs-number">0</span>),<span class="hljs-attr">std</span>::cout.tie(<span class="hljs-number">0</span>);<br>#define MAX <span class="hljs-number">88888888</span><br>#define INF <span class="hljs-number">0x3f</span><br>#define r0 <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>#define SYP system(<span class="hljs-string">&quot;pause&quot;</span>);<br>#define endl <span class="hljs-string">&#x27;\n&#x27;</span><br><br><br><br>STD<br>int main()<br>&#123;<br>    IOS<br>    ll a;<br>    cin&gt;&gt;a;<br>    ll ans=<span class="hljs-number">0</span>;<br>    <span class="hljs-keyword">while</span> (a)<br>    &#123;<br>        <span class="hljs-keyword">if</span>(a%<span class="hljs-number">2</span>==<span class="hljs-number">1</span>)ans++;<br>        a&gt;&gt;=<span class="hljs-number">1</span>;<br>    &#125;<br>    cout&lt;&lt;ans&lt;&lt;<span class="hljs-string">&#x27;\n&#x27;</span>;<br>    <span class="hljs-comment">//SYP</span><br>    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>&#125;<br></code></pre></td></tr></table></figure>

<h1 id="B-实数加法（大浮点数）"><a href="#B-实数加法（大浮点数）" class="headerlink" title="B - 实数加法（大浮点数）"></a>B - 实数加法（大浮点数）</h1><p>原题链接：<a target="_blank" rel="noopener" href="https://nanti.jisuanke.com/t/T1180">B - 实数加法</a><br>题意：大浮点数相加，形如：ppppppp.qqqqqqq<br>题解：emmm怎么说呢，大数这玩意说难不难说简单不简单，一个对新手来说考验码力和细节的东西，第一次写是快八个月前了，先后写过好几次，到现在还是不够熟悉。鸿✌说建议学手java或者存个板子，是个好主意。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br></pre></td><td class="code"><pre><code class="hljs javascript">        <span class="hljs-comment">// violet apricity</span><br><span class="hljs-comment">// Do all I can do.Do good to be good.</span><br><br>#include&lt;iostream&gt;<br>#include&lt;stdio.h&gt;<br>#include&lt;cstring&gt;<br>#include&lt;string&gt;<br>#include&lt;algorithm&gt;<br>#include&lt;vector&gt;<br>#include&lt;math.h&gt;<br>#include&lt;map&gt;<br>#include&lt;sstream&gt;<br><br>#define STD using namespace std;<br>#define ll long long<br>#define db double<br>#define ldb long double<br>#define IOS std::ios::sync_with_stdio(<span class="hljs-literal">false</span>),<span class="hljs-attr">std</span>::cin.tie(<span class="hljs-number">0</span>),<span class="hljs-attr">std</span>::cout.tie(<span class="hljs-number">0</span>);<br>#define MAX <span class="hljs-number">88888888</span><br>#define INF <span class="hljs-number">0x3f</span><br>#define r0 <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>#define SYP system(<span class="hljs-string">&quot;pause&quot;</span>);<br>#define endl <span class="hljs-string">&#x27;\n&#x27;</span><br><br><br>int a[<span class="hljs-number">1111</span>],b[<span class="hljs-number">1111</span>],len;<br>int main()<br>&#123;<br>    IOS<br>    char x;<br>    std::string s1=<span class="hljs-string">&quot;&quot;</span>,s3=<span class="hljs-string">&quot;&quot;</span>,s2=<span class="hljs-string">&quot;&quot;</span>,s4=<span class="hljs-string">&quot;&quot;</span>;<br>    <span class="hljs-comment">//来存下数字，注意整数部分要倒着存，因为是数组存运算时进位要方便</span><br>    <span class="hljs-comment">//相反，因为相加方向不一样，小数不需要倒着存</span><br>    <span class="hljs-keyword">while</span>(std::cin&gt;&gt;x&amp;&amp;x!=<span class="hljs-string">&#x27;.&#x27;</span>)s1=x+s1;<span class="hljs-comment">//存a整数部分</span><br>    std::cin&gt;&gt;s2;<span class="hljs-comment">//存a小数部分</span><br>    <span class="hljs-keyword">while</span>(std::cin&gt;&gt;x&amp;&amp;x!=<span class="hljs-string">&#x27;.&#x27;</span>)s3=x+s3;<span class="hljs-comment">//存b整数部分</span><br>    std::cin&gt;&gt;s4;<span class="hljs-comment">//存b小数部分</span><br>    <span class="hljs-keyword">if</span>(s1.length()&lt;s3.length())swap(s1,s3);<span class="hljs-comment">//先处理短的</span><br>    <span class="hljs-keyword">for</span>(int i=<span class="hljs-number">0</span>;i&lt;s3.length();i++)&#123;<span class="hljs-comment">//遍历短的相同部分相加</span><br>        a[i]+=s1[i]+s3[i]-<span class="hljs-number">2</span>*<span class="hljs-string">&#x27;0&#x27;</span>;<br>        <span class="hljs-keyword">if</span>(a[i]&gt;=<span class="hljs-number">10</span>)<span class="hljs-comment">//进位</span><br>        &#123;<br>            a[i+<span class="hljs-number">1</span>]+=a[i]/<span class="hljs-number">10</span>;<br>            a[i]%=<span class="hljs-number">10</span>;<br>        &#125;<br>    &#125;<br>    <span class="hljs-keyword">for</span>(int i=s3.length();i&lt;s1.length();i++)&#123;<span class="hljs-comment">//长的多出来那一部分</span><br>        a[i]+=s1[i]-<span class="hljs-string">&#x27;0&#x27;</span>;<br>        <span class="hljs-keyword">if</span>(a[i]&gt;=<span class="hljs-number">10</span>)<br>        &#123;<br>            a[i+<span class="hljs-number">1</span>]+=a[i]/<span class="hljs-number">10</span>;<br>            a[i]%=<span class="hljs-number">10</span>;<br>        &#125;<br>    &#125;<br>    <span class="hljs-keyword">if</span>(a[s1.length()]) len=s1.length();<span class="hljs-keyword">else</span> len=s1.length()-<span class="hljs-number">1</span>;<br>    <span class="hljs-comment">//最后是否进位导致边长了一位</span><br>    <span class="hljs-comment">//注意小数和整数相加的差异（方向相反）</span><br>    <span class="hljs-keyword">if</span>(s2.length()&lt;s4.length())swap(s2,s4);<br>    <span class="hljs-keyword">for</span>(int i=<span class="hljs-number">0</span>;i&lt;s4.length();i++) b[i]=s2[i]+s4[i]-<span class="hljs-number">2</span>*<span class="hljs-string">&#x27;0&#x27;</span>;<br>    <span class="hljs-keyword">for</span>(int i=s4.length();i&lt;s2.length();i++) b[i]=s2[i]-<span class="hljs-string">&#x27;0&#x27;</span>;<br>    <span class="hljs-keyword">for</span>(int i=s2.length()-<span class="hljs-number">1</span>;i&gt;=<span class="hljs-number">0</span>;i--)&#123;<br>        <span class="hljs-keyword">if</span>(i==<span class="hljs-number">0</span>&amp;&amp;b[i]&gt;=<span class="hljs-number">10</span>)<span class="hljs-comment">//进位到个位去了</span><br>        &#123;<br>            a[<span class="hljs-number">0</span>]++;<br>            b[<span class="hljs-number">0</span>]-=<span class="hljs-number">10</span>;<br>        &#125;<br>        <span class="hljs-keyword">else</span><br>        <span class="hljs-keyword">if</span>(b[i]&gt;=<span class="hljs-number">10</span>)<span class="hljs-comment">//还没进位到个位</span><br>        &#123;<br>            b[i-<span class="hljs-number">1</span>]++;<br>            b[i]-=<span class="hljs-number">10</span>;<br>        &#125;<br>    &#125;<br>    int i=<span class="hljs-number">0</span>;<br>    <span class="hljs-keyword">while</span>(a[i]&gt;=<span class="hljs-number">10</span>)&#123;<span class="hljs-comment">//小数相加的时候进了位要再处理一次整数进位</span><br>        a[i+<span class="hljs-number">1</span>]++;<br>        a[i]-=<span class="hljs-number">10</span>;<br>        i++;<br>    &#125;<br>    len=std::max(len,i);<span class="hljs-comment">//进位后改变长度</span><br>    <span class="hljs-keyword">for</span>(int j=len;j&gt;=<span class="hljs-number">0</span>;j--)std::cout&lt;&lt;a[j];<span class="hljs-comment">//输出整数部分</span><br>    std::cout&lt;&lt;<span class="hljs-string">&#x27;.&#x27;</span>;<br>    int d=<span class="hljs-number">0</span>;<br>    <span class="hljs-keyword">for</span>(int j=s2.length()-<span class="hljs-number">1</span>;j&gt;=<span class="hljs-number">0</span>;j--)<span class="hljs-keyword">if</span>(b[j])&#123;d=j;<span class="hljs-keyword">break</span>;&#125;<span class="hljs-comment">//后往前找到非0，即去掉后导0不输出</span><br>    <span class="hljs-keyword">for</span>(i=<span class="hljs-number">0</span>;i&lt;=d;i++)std::cout&lt;&lt;b[i];<span class="hljs-comment">//输出小数部分</span><br>    std::cout&lt;&lt;<span class="hljs-string">&#x27;\n&#x27;</span>;<span class="hljs-comment">//OVER</span><br>    <span class="hljs-comment">//SYP</span><br>    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>&#125;<br></code></pre></td></tr></table></figure>

<h1 id="C-幂次方（递归-栈模拟）"><a href="#C-幂次方（递归-栈模拟）" class="headerlink" title="C - 幂次方（递归+栈模拟）"></a>C - 幂次方（递归+栈模拟）</h1><p>原题链接：<a target="_blank" rel="noopener" href="https://nanti.jisuanke.com/t/T2103">计蒜客 - T2103 </a><br>题意：用括号的方式把一个非负整数用2的幂次方和表示。<br>题解：这和寒假在紫书上看的括号序列相比难度低了好多（根本比不了）。可以用栈模拟一下，大概就是：<br>1.solve(n)对n先取个log(2)得到temp，然后对内部分情况处理：<br>     ·若temp&gt;2：说明内部还可以再分，先输出此时的2，再solve(temp)<br>     ·若temp==1：说明刚刚好，输出2结束了<br>     ·否则输出按正常输出2(temp)<br>2.然后处理外部：res=n-temp，若res&gt;0说明外部还有，则：<br>输出+再solve(res)处理外部部分。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br></pre></td><td class="code"><pre><code class="hljs javascript">        <span class="hljs-comment">// violet apricity</span><br><span class="hljs-comment">// Do all I can do.Do good to be good.</span><br><br>#include&lt;iostream&gt;<br>#include&lt;stdio.h&gt;<br>#include&lt;cstring&gt;<br>#include&lt;string&gt;<br>#include&lt;algorithm&gt;<br>#include&lt;vector&gt;<br>#include&lt;math.h&gt;<br>#include&lt;map&gt;<br>#include&lt;sstream&gt;<br><br>#define STD using namespace std;<br>#define ll long long<br>#define db double<br>#define ldb long double<br>#define IOS std::ios::sync_with_stdio(<span class="hljs-literal">false</span>),<span class="hljs-attr">std</span>::cin.tie(<span class="hljs-number">0</span>),<span class="hljs-attr">std</span>::cout.tie(<span class="hljs-number">0</span>);<br>#define MAX <span class="hljs-number">88888888</span><br>#define INF <span class="hljs-number">0x3f</span><br>#define r0 <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>#define SYP system(<span class="hljs-string">&quot;pause&quot;</span>);<br>#define endl <span class="hljs-string">&#x27;\n&#x27;</span><br><br><br><br><br><span class="hljs-keyword">const</span> int mod=<span class="hljs-number">10007</span>;<br><span class="hljs-keyword">void</span> solve(ll n)<br>&#123;<br>     int d=<span class="hljs-number">2</span>;<br>     int cnt=<span class="hljs-number">0</span>;<br>     int temp=log(n)/log(<span class="hljs-number">2</span>);<br>     <span class="hljs-keyword">if</span>(temp&gt;<span class="hljs-number">2</span>)&#123;<br>        std::cout&lt;&lt;<span class="hljs-string">&quot;2(&quot;</span>;<br>        solve(temp);<br>        std::cout&lt;&lt;<span class="hljs-string">&quot;)&quot;</span>;<br>     &#125;<br>     <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(temp==<span class="hljs-number">1</span>)&#123;<br>        std::cout&lt;&lt;<span class="hljs-string">&quot;2&quot;</span>;<br>     &#125;<br>     <span class="hljs-keyword">else</span> &#123;<br>        std::cout&lt;&lt;<span class="hljs-number">2</span>&lt;&lt;<span class="hljs-string">&quot;(&quot;</span>&lt;&lt;temp&lt;&lt;<span class="hljs-string">&quot;)&quot;</span>;<br>     &#125;<br>     int res=n-(int)std::pow(<span class="hljs-number">2</span>,temp);<br>     <span class="hljs-keyword">if</span>(res&gt;<span class="hljs-number">0</span>)&#123;<br>        std::cout&lt;&lt;<span class="hljs-string">&quot;+&quot;</span>;<br>        solve(res);<br>     &#125;<br>&#125;<br>int main()<br>&#123;<br>    IOS<br>    ll n;<br>    std::cin&gt;&gt;n;<br>    solve(n);<br>    std::cout&lt;&lt;<span class="hljs-string">&#x27;\n&#x27;</span>;<br>    <span class="hljs-comment">//SYP</span><br>    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>&#125;<br></code></pre></td></tr></table></figure>

<h1 id="D-新运算（模拟）"><a href="#D-新运算（模拟）" class="headerlink" title="D - 新运算（模拟）"></a>D - 新运算（模拟）</h1><p>原题链接：<a target="_blank" rel="noopener" href="https://nanti.jisuanke.com/t/T1765">计蒜客 - T1765 </a><br>题意：定义了三种新运算符。输入一堆数轮流三种运算取模后输出结果。<br>题解：直接模拟即可。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><code class="hljs javascript">        <span class="hljs-comment">// violet apricity</span><br><span class="hljs-comment">// Do all I can do.Do good to be good.</span><br><br>#include&lt;iostream&gt;<br>#include&lt;stdio.h&gt;<br>#include&lt;cstring&gt;<br>#include&lt;string&gt;<br>#include&lt;algorithm&gt;<br>#include&lt;vector&gt;<br>#include&lt;math.h&gt;<br>#include&lt;map&gt;<br>#include&lt;sstream&gt;<br><br>#define STD using namespace std;<br>#define ll long long<br>#define db double<br>#define ldb long double<br>#define IOS std::ios::sync_with_stdio(<span class="hljs-literal">false</span>),<span class="hljs-attr">std</span>::cin.tie(<span class="hljs-number">0</span>),<span class="hljs-attr">std</span>::cout.tie(<span class="hljs-number">0</span>);<br>#define MAX <span class="hljs-number">88888888</span><br>#define INF <span class="hljs-number">0x3f</span><br>#define r0 <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>#define SYP system(<span class="hljs-string">&quot;pause&quot;</span>);<br>#define endl <span class="hljs-string">&#x27;\n&#x27;</span><br><br><br><br>STD<br><span class="hljs-keyword">const</span> int mod=<span class="hljs-number">10007</span>;<br>int main()<br>&#123;<br>    IOS<br>    ll n;<br>    cin&gt;&gt;n;<br>    ll cnt=<span class="hljs-number">0</span>;<br>    ll ans=<span class="hljs-number">0</span>;<br>    cin&gt;&gt;ans;<br>    n--;<br>    <span class="hljs-keyword">while</span>(n--)&#123;<br>        ll x;cin&gt;&gt;x;<br>        <span class="hljs-keyword">if</span>(cnt==<span class="hljs-number">0</span>)ans=((ans*ans%mod)+(x*x%mod))%mod;<br>        <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(cnt==<span class="hljs-number">1</span>)ans=((ans*ans%mod*ans%mod)%mod+x)%mod;<br>        <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(cnt==<span class="hljs-number">2</span>)ans=(ans+(x*x%mod*x%mod)%mod)%mod;<br>        cnt++;<br>        cnt%=<span class="hljs-number">3</span>;<br>    &#125;<br>    cout&lt;&lt;ans&lt;&lt;<span class="hljs-string">&#x27;\n&#x27;</span>;<br>    <span class="hljs-comment">//SYP</span><br>    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>&#125;<br></code></pre></td></tr></table></figure>

<p>到此为止前四到简单题，下面的都是有点难度的，我只会写E，还是莫名其妙过的。</p>
<h1 id="E-Subsequence"><a href="#E-Subsequence" class="headerlink" title="E - Subsequence"></a>E - Subsequence</h1><p>原题链接：<a target="_blank" rel="noopener" href="https://nanti.jisuanke.com/t/38232">计蒜客 - 38232</a><br>题意：给出一个母串和n个子串，判断子串是否位母串的子串。<br>题解：可以暴力过，也可以两个数组存个位置。<br>师兄题解是这么说的：序列自动机，就是找每个点右边的每个字符的位置。<br>我还不清楚自动机，记得好像写过类似的瞎搞就过了。<br>我的代码：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br></pre></td><td class="code"><pre><code class="hljs javascript">        <span class="hljs-comment">// violet apricity</span><br><span class="hljs-comment">// Do all I can do.Do good to be good.</span><br><br>#include&lt;iostream&gt;<br>#include&lt;stdio.h&gt;<br>#include&lt;cstring&gt;<br>#include&lt;string&gt;<br>#include&lt;algorithm&gt;<br>#include&lt;vector&gt;<br>#include&lt;math.h&gt;<br>#include&lt;map&gt;<br>#include&lt;sstream&gt;<br><br>#define STD using namespace std;<br>#define ll long long<br>#define db double<br>#define ldb long double<br>#define IOS std::ios::sync_with_stdio(<span class="hljs-literal">false</span>),<span class="hljs-attr">std</span>::cin.tie(<span class="hljs-number">0</span>),<span class="hljs-attr">std</span>::cout.tie(<span class="hljs-number">0</span>);<br>#define MAX <span class="hljs-number">88888888</span><br>#define INF <span class="hljs-number">0x3f</span><br>#define r0 <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>#define SYP system(<span class="hljs-string">&quot;pause&quot;</span>);<br>#define endl <span class="hljs-string">&#x27;\n&#x27;</span><br><br><br><br><span class="hljs-keyword">const</span> int N=<span class="hljs-number">111111</span>;<br>int a[<span class="hljs-number">100</span>];<br>int b[<span class="hljs-number">100</span>];<br>std::vector&lt;int&gt;ans;<br><span class="hljs-keyword">const</span> int mod=<span class="hljs-number">10007</span>;<br>char s[N],c[N];<br>int has[N][<span class="hljs-number">130</span>];<br><span class="hljs-keyword">void</span> pre(int x,int y)<br>&#123;<br>    <span class="hljs-keyword">for</span>(int i=<span class="hljs-number">0</span>; i&lt;<span class="hljs-number">130</span>; i++)has[x][i]=has[x+<span class="hljs-number">1</span>][i];<br>    has[x][y]=x;<br>&#125;<br>int main()<br>&#123;<br>    IOS<br>    std::cin&gt;&gt;s;<br>    int n;<br>    std::cin&gt;&gt;n;<br>    int len=strlen(s);<br>    memset(has,-<span class="hljs-number">1</span>,sizeof(has));<br>    <span class="hljs-keyword">for</span>(int i=len-<span class="hljs-number">1</span>; i&gt;=<span class="hljs-number">0</span>; i--)<br>    &#123;<br>        int x=(int)s[i];<br>        pre(i,x);<br>    &#125;<br>    <span class="hljs-keyword">while</span>(n--)<br>    &#123;<br>        std::cin&gt;&gt;c;<br>        int temp=strlen(c);<br>        int i=<span class="hljs-number">0</span>,j=<span class="hljs-number">0</span>;<br>        <span class="hljs-keyword">for</span>(j=<span class="hljs-number">0</span>; j&lt;temp; j++)<br>        &#123;<br>            int x=(int)c[j];<br>            int y=has[i][x];<br>            <span class="hljs-keyword">if</span>(y&lt;i)<span class="hljs-keyword">break</span>;<br>            i=y+<span class="hljs-number">1</span>;<br>        &#125;<br>        <span class="hljs-keyword">if</span>(j&gt;=temp)std::cout&lt;&lt;<span class="hljs-string">&quot;YES\n&quot;</span>;<br>        <span class="hljs-keyword">else</span> std::cout&lt;&lt;<span class="hljs-string">&quot;NO\n&quot;</span>;<br>    &#125;<br>    <span class="hljs-comment">//SYP</span><br>    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>&#125;<br></code></pre></td></tr></table></figure>

<p>师兄的代码：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><code class="hljs javascript">#include&lt;bits/stdc++.h&gt;<br>using namespace std;<br>#define ll long long<br>char s[<span class="hljs-number">100010</span>],t[<span class="hljs-number">1010</span>];<br>int nxt[<span class="hljs-number">100010</span>][<span class="hljs-number">26</span>];<br>int <span class="hljs-function"><span class="hljs-title">main</span>(<span class="hljs-params"></span>)</span>&#123;<br>    ios::sync_with_stdio(<span class="hljs-number">0</span>);<br>    cin.tie(<span class="hljs-number">0</span>);cout.tie(<span class="hljs-number">0</span>);<br>    cin&gt;&gt;s+<span class="hljs-number">1</span>;<br>    int n=strlen(s+<span class="hljs-number">1</span>);<br>    <span class="hljs-comment">//建序列自动机</span><br>    <span class="hljs-keyword">for</span>(int i=<span class="hljs-number">0</span>;i&lt;<span class="hljs-number">26</span>;i++) nxt[n][i]=n+<span class="hljs-number">1</span>;<br>    <span class="hljs-keyword">for</span>(int i=n-<span class="hljs-number">1</span>;i&gt;=<span class="hljs-number">0</span>;i--)&#123;<br>        <span class="hljs-keyword">for</span>(int j=<span class="hljs-number">0</span>;j&lt;<span class="hljs-number">26</span>;j++)<br>         nxt[i][j]=(s[i+<span class="hljs-number">1</span>]==<span class="hljs-string">&#x27;a&#x27;</span>+j?i+<span class="hljs-number">1</span>:nxt[i+<span class="hljs-number">1</span>][j]);<br>    &#125;<br>    int m;<br>    cin&gt;&gt;m;<br>    <span class="hljs-keyword">while</span>(m--)&#123;<br>      cin&gt;&gt;t+<span class="hljs-number">1</span>;<br>      int len=strlen(t+<span class="hljs-number">1</span>);<br>      int i=<span class="hljs-number">0</span>,j=<span class="hljs-number">0</span>;<br>      <span class="hljs-keyword">while</span>(i&lt;len+<span class="hljs-number">1</span>)&#123;<br>        j=nxt[j][t[i]-<span class="hljs-string">&#x27;a&#x27;</span>];<br>        <span class="hljs-keyword">if</span>(j==n+<span class="hljs-number">1</span>) <span class="hljs-keyword">break</span>;<br>        i++;<br>      &#125;<br>      <span class="hljs-keyword">if</span>(i==len+<span class="hljs-number">1</span>) cout&lt;&lt;<span class="hljs-string">&quot;YES&quot;</span>&lt;&lt;<span class="hljs-string">&#x27;\n&#x27;</span>;<br>      <span class="hljs-keyword">else</span> cout&lt;&lt;<span class="hljs-string">&quot;NO&quot;</span>&lt;&lt;<span class="hljs-string">&#x27;\n&#x27;</span>;<br>    &#125;<br>&#125;<br></code></pre></td></tr></table></figure>

<p>下面的暂时不会啦，留着以后补吧。<br>        &gt;_&lt;<br>じゃ、またね</p>

            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/ACM/">ACM</a>
                    
                      <a class="hover-with-bg" href="/tags/%E5%B9%BF%E5%B7%9E%E5%A4%A7%E5%AD%A6/">广州大学</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">
                  
                    本博客所有文章除特别声明外，均采用 <a target="_blank" href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！
                  
                </p>
              
              
                <div class="post-prevnext">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2021/04/17/Codeforces-Round-715-Div-2-2021-04-16/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">CFR715(Div.2)2021.04.16</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2021/04/16/Educational-Codeforces-Round-107-Rated-for-Div-2/">
                        <span class="hidden-mobile">ECFR107(Div.2)2021.04.13</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    

    
      <a id="scroll-top-button" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
    

    
  </main>

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
  </div>
  

  

  
</footer>


  <!-- SCRIPTS -->
  
  <script  src="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js" ></script>
<script  src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js" ></script>
<script  src="/js/debouncer.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>

<!-- Plugins -->


  
    <script  src="/js/img-lazyload.js" ></script>
  



  



  <script  src="https://cdn.jsdelivr.net/npm/tocbot@4.12.0/dist/tocbot.min.js" ></script>



  <script  src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js" ></script>



  <script  src="https://cdn.jsdelivr.net/npm/anchor-js@4.3.0/anchor.min.js" ></script>



  <script defer src="https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js" ></script>






  <script  src="https://cdn.jsdelivr.net/npm/typed.js@2.0.11/lib/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var title = document.getElementById('subtitle').title;
      
      typing(title)
      
    })(window, document);
  </script>



  <script  src="/js/local-search.js" ></script>
  <script>
    (function () {
      var path = "/local-search.xml";
      $('#local-search-input').on('click', function() {
        searchFunc(path, 'local-search-input', 'local-search-result');
      });
      $('#modalSearch').on('shown.bs.modal', function() {
        $('#local-search-input').focus();
      });
    })()
  </script>















<!-- 主题的启动项 保持在最底部 -->
<script  src="/js/boot.js" ></script>


</body>
</html>
